<!-- 首次关注优惠券 -->
<template>
    <popup :value="showToast" height="75%" style="background-color: white">
        <p class="h44 tc c1 f18">恭喜您获取优惠券</p>
        <div class="px12 ofay scroll">
            <item v-for="(i, index) in list" :data="i" :key="index"></item>
        </div>
        <div @click="close" class="abs posbl bottom fitw mb10" flex="main:center cross:center" style="z-index: 1">
            <i class="iconfont icon-cha close white"></i>
        </div>
    </popup>
</template>
<script>
  import item from '../优惠券/_item.vue'

  export default {
    props: ['list'],
    data () {
      return {
        showToast: true,
        ajax_delay_once: false
      }
    },
    async created () {
      /*
      *  首先读取用户信息，判断用户是不是已经关注微信公众号
      *  没有则请求后台，有则不请求
      * */
      // 判断没有关注 就请求后台,后台要求的
      if (!this.userInfo.isFollow) {
        await this.$get('wx/isConcern')
      }

      // 获取收到的优惠券
    },
    computed: {
      userInfo () {
        return this.$store.getters.userInfo
      },
    },
    methods: {
      async close () {
        this.showToast = false
        await sleep(300)
        this.$el.remove()
        this.$destroy()
      }
    },
    components: {
      item
    }
  }
</script>
<style type="text/scss" lang="scss" scoped>
    .close {
        $size: 1.6em;
        background-color: rgba(0, 0, 0, .125);
        border-radius: 50%;
        font-size: 32px;
        width: $size;
        height: $size;
        line-height: $size;
        text-align: center;
    }

    .scroll {
        position: absolute;
        top: 44px;
        left: 0px;
        bottom: 0px;
        right: 0px;
        height: auto;
    }
</style>
